package logic

import (
	"context"
	"user_srv/model/mysql"

	"user_srv/internal/svc"
	"user_srv/user"

	"github.com/zeromicro/go-zero/core/logx"
)

type CreateRealNameLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewCreateRealNameLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateRealNameLogic {
	return &CreateRealNameLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// 创建实名信息

func (l *CreateRealNameLogic) CreateRealName(in *user.CreateRealNameReq) (*user.CreateRealNameResp, error) {
	u := mysql.UserRealName{
		UserId:   int(in.UserId),
		RealName: in.RealName,
		IdCard:   in.IdCard,
	}
	err := u.Create()
	if err != nil {
		logx.Error("实名创建信息失败")
		return nil, err
	}
	return &user.CreateRealNameResp{}, nil
}
